<?php
function get_link(){
    global $link;
    if($link==null) {
        $link = mysql_connect("localhost","root","") or die ("can't connect database");
        mysql_selectdb("th2a") or die ("database doesn't exist");    
    }
    return $link;
}

function get_menu($type){
    global $link;
    $strSql="select * from categories where type=$type";
    $result= mysql_query($strSql,$link);
    return $result;
}

function get_sanpham(){
    global $link; 
    $strSql="select * from product";;
    $result= mysql_query($strSql,$link);
    return $result;
}

function draw_box($title, $data){ 
        echo '<h2 class="title">',$title,'</h2>';       
        echo '<ul>';                                                            
            while($row = mysql_fetch_array($data)){                                        
                echo'<li><a href="#">',$row['name'],'</a></li>';                
            }                        
        echo '</ul>';
}